<template>
  <div class="home">
    <!-- Remove duplicate Header component (already in App.vue) -->
    
    <!-- 轮播图 -->
    <div class="banner">
      <el-carousel height="400px">
        <el-carousel-item v-for="item in banners" :key="item.id">
          <div class="banner-item" :style="{ backgroundImage: `url(${item.image})` }">
            <div class="banner-content">
              <h2>{{ item.title }}</h2>
              <p>{{ item.description }}</p>
            </div>
          </div>
        </el-carousel-item>
      </el-carousel>
    </div>

    <!-- 功能模块 -->
    <div class="features">
      <div class="container">
        <h2 class="section-title">{{$t('coreFeatures')}}</h2>
        <div class="features-grid">
          <div class="feature-card" @click="$router.push('/about')">
            <el-icon class="feature-icon"><InfoFilled /></el-icon>
            <h3>{{$t('featureAboutTitle')}}</h3>
            <p>{{$t('featureAboutDesc')}}</p>
          </div>
          <div class="feature-card" @click="$router.push('/news')">
            <el-icon class="feature-icon"><Document /></el-icon>
            <h3>{{$t('featureNewsTitle')}}</h3>
            <p>{{$t('featureNewsDesc')}}</p>
          </div>
          <div class="feature-card" @click="$router.push('/detection')">
            <el-icon class="feature-icon"><Monitor /></el-icon>
            <h3>{{$t('featureDetectTitle')}}</h3>
            <p>{{$t('featureDetectDesc')}}</p>
          </div>
        </div>
      </div>
    </div>

    <!-- 最新新闻 -->
    <div class="latest-news">
      <div class="container">
        <h2 class="section-title">{{$t('latestSection')}}</h2>
        <div class="news-grid">
          <div v-for="news in latestNews" :key="news.id" class="news-card">
            <img :src="news.image" :alt="news.title" class="news-image" />
            <div class="news-content">
              <h3>{{ news.title }}</h3>
              <p>{{ news.summary }}</p>
              <span class="news-date">{{ news.date }}</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// Import required Element Plus icons
import { InfoFilled, Document, Monitor } from '@element-plus/icons-vue'

export default {
  name: 'Home',
  components: {
    // Register the icons
    InfoFilled,
    Document,
    Monitor
  },
  data() {
    return {
      banners: [
        {
          id: 1,
          title: this.$t('homeBanner1Title'),
          description: this.$t('homeBanner1Desc'),
          image: 'https://images.unsplash.com/photo-1574323347407-f5e1ad6d020b?w=1200&h=400&fit=crop'
        },
        {
          id: 2,
          title: this.$t('homeBanner2Title'),
          description: this.$t('homeBanner2Desc'),
          image: 'https://images.unsplash.com/photo-1556909114-f6e7ad7d3136?w=1200&h=400&fit=crop'
        }
      ],
      latestNews: [
        {
          id: 1,
          title: this.$lang && this.$lang.language==='en' ? 'New national standard for wheat quality testing released' : '2024年小麦品质检测新标准发布',
          summary: this.$lang && this.$lang.language==='en' ? 'New standard improves testing accuracy and efficiency' : '国家发布最新小麦品质检测标准，提升检测精度和效率',
          image: 'https://images.unsplash.com/photo-1581094794329-c8112a89af12?w=300&h=200&fit=crop',
          date: '2024-01-15'
        },
        {
          id: 2,
          title: this.$lang && this.$lang.language==='en' ? 'New testing equipment put into use' : '新型检测设备投入使用',
          summary: this.$lang && this.$lang.language==='en' ? 'Advanced equipment greatly improves accuracy and efficiency' : '引进国际先进检测设备，大幅提升检测准确性和效率',
          image: 'https://images.unsplash.com/photo-1581094794329-c8112a89af12?w=300&h=200&fit=crop',
          date: '2024-01-10'
        }
      ]
    }
  }
}
</script>

<style scoped>
.home {
  min-height: 100vh;
  background: var(--color-bg);
}

.banner {
  margin-bottom: 3rem;
}

.banner-item {
  height: 400px;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-radius: 18px;
  box-shadow: var(--color-shadow);
  overflow: hidden;
}

/* 移除渐隐蒙版 */

.banner-content {
  text-align: center;
  color: #fff;
  z-index: 1;
  position: relative;
}

.banner-content h2 {
  font-size: 2.8rem;
  margin-bottom: 1rem;
  font-weight: bold;
  letter-spacing: 2px;
}

.banner-content p {
  font-size: 1.3rem;
  max-width: 600px;
  margin: 0 auto;
  color: #eafaf1;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

.section-title {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 3rem;
  color: var(--color-primary);
  letter-spacing: 1px;
}

.features {
  padding: 4rem 0;
  background: var(--color-card-bg);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.feature-card {
  background: #fff;
  padding: 2rem;
  border-radius: 16px;
  box-shadow: var(--color-shadow);
  text-align: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(.4,2,.3,1);
  border: 1.5px solid var(--color-border);
}

.feature-card:hover {
  transform: translateY(-8px) scale(1.03);
  box-shadow: 0 16px 32px rgba(20,90,50,0.13);
  border-color: var(--color-primary-light);
  background: var(--color-primary-light);
}

.feature-icon {
  font-size: 3rem;
  color: var(--color-primary);
  margin-bottom: 1rem;
}

.feature-card h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--color-primary);
}

.feature-card p {
  color: var(--color-text-light);
  line-height: 1.6;
}

.latest-news {
  padding: 4rem 0;
  background: var(--color-card-bg);
}

.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 2rem;
}

.news-card {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--color-shadow);
  transition: all 0.3s cubic-bezier(.4,2,.3,1);
  border: 1.5px solid var(--color-border);
}

.news-card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 10px 25px rgba(20,90,50,0.13);
  border-color: var(--color-primary-light);
}

.news-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.news-content {
  padding: 1.5rem;
}

.news-content h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--color-primary);
}

.news-content p {
  color: var(--color-text-light);
  margin-bottom: 1rem;
  line-height: 1.6;
}

.news-date {
  color: #999;
  font-size: 0.9rem;
}

@media (max-width: 768px) {
  .banner-content h2 {
    font-size: 2rem;
  }
  .features-grid,
  .news-grid {
    grid-template-columns: 1fr;
  }
  .banner-item {
    height: 220px;
  }
}
</style> 